package at.codebase.core;

import java.math.BigInteger;

/**
 * Stores bit flags and provides basic operations
 * for them. These flags can be used for authorization
 * checks.
 * 
 * @author Daniel Marth <danielmarth@gmx.at>
 */
public class BitFlags {

	private final BigInteger flags;
	
	public BitFlags() {
		this(0L);
	}
	
	public BitFlags(final BitFlags other) {
		this(other.flags);
	}
	
	public BitFlags(final long f) {
		flags = new BigInteger(String.valueOf(f));
	}
	
	public BitFlags(final BigInteger f) {
		flags = new BigInteger(f.toString());
	}
	
	public BitFlags and(final BitFlags other) {
		return new BitFlags(flags.and(other.flags));
	}
	
	public BitFlags or(final BitFlags other) {
		return new BitFlags(flags.or(other.flags));
	}
	
	public BigInteger value() {
		return flags;
	}
	
	public boolean equals(final BitFlags other) {
		return flags.equals(other.flags);
	}
	
}
